import { post } from "../../../utils/request";
const env = import.meta.env;

const apiUpload = {
  queryFile(businessKey: string, category: string) {
    return post(env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/sms.listing", {
      businessKey,
      category,
    });
  },
  uploadImage(formData: FormData) {
    return post(
      env.VITE_API_ADMIN_CONTEXT_PATH + "/open/image.upload",
      formData
    );
  },
  uploadUrl() {
    return (
      // env.VITE_API_URL +
      env.VITE_API_ADMIN_CONTEXT_PATH + "/open/file.upload"
    );
  },
  downloadUrl(fileId: string) {
    return (
      // env.VITE_API_URL +
      env.VITE_API_ADMIN_CONTEXT_PATH + "/open/file.download/" + fileId
    );
  },
  editorUrl(fileId: string) {
    // 图片编辑器下载 url，因编辑器 html 会存储到数据库，所以需要使用相对路径，不能使用决定路径
    return env.VITE_API_ADMIN_CONTEXT_PATH + "/open/file.download/" + fileId;
  },
};

export default apiUpload;
